package com.beinhospital_sw21_h2_05.beinhospitalsw21h205.mapper;

import com.beinhospital_sw21_h2_05.beinhospitalsw21h205.entity.Department;
import lombok.Data;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DepartmentMapper {

    /**
     * 根据科室名称模糊查询科室列表。
     *
     * @param departmentName 用于过滤的科室名称（可为null）
     * @return 包含科室列表的List
     */
    List<Department> list(String departmentName);

    /**
     * 根据科室ID删除科室信息。
     *
     * @param departmentID 科室ID
     */
    @Delete("delete from Department where departmentID = #{departmentID}")
    void delete(Integer departmentID);

    /**
     * 插入新的科室信息。
     *
     * @param department 待插入的科室对象
     */
    @Insert("insert into Department(DepartmentName) values(#{DepartmentName})")
    void insert(Department department);

    /**
     * 根据科室ID更新科室信息。
     *
     * @param department 待更新的科室对象
     */
    @Update("update Department set DepartmentName = #{DepartmentName} where departmentID = #{departmentID}")
    void update(Department department);
}
